<?php
  session_start();
  header("content-type=textml; charset=utf-8");  //设置字符集
  date_default_timezone_set('PRC');  //设置中国时区
  require("config.php");  //包含数据库连接文件
  //按钮是否为空
if(!empty($_POST['submit']))
{
  //不为空则进行以下操作
  $title  = $_POST['title'];//标题
  $author  = $_POST['author'];//作者
  $high_name  = $_POST['high_name'];//所属模型
  $middle_name = $_POST['middle_name'];//栏目类别
  $elementary_name = $_POST['elementary_name'];//栏目名称
  $content =  $_POST['editor.getContent()'];
  $time  = time();//当前时间戳 

  //插入到文章表
  $insert_sql="INSERT INTO article (title,time,author,content) VALUES ('$title','$time','$author','$content')";
  $result = mysql_query($insert_sql);

  //插入到所属模型表
  $insert= "INSERT INTO high_level (high_name) VALUES('$high_name')";
  $rs = mysql_query($insert);

  //插入到栏目类别表
  $in= "INSERT INTO middle_level (middle_name) VALUES('$middle_name')";
  $re = mysql_query($in);
  //插入到栏目名称表
  $ins= "INSERT INTO elementary_level (elementary_name) VALUES('$elementary_name')";
  $res = mysql_query($ins);

  if($result && $rs && $re && $res && mysql_affected_rows()>0)
  {
	  echo "<script>alert('恭喜您，你的文章发表成功!!!');window.location.href='file.html';</script>";
  }
  else
  {
	  echo "<script>alert('对不起，添加操作失败!!!');</script>";
  }
}
//mysql_free_result($result);  //释放查询的结果集资源
//mysql_free_result($rs);
//关闭服务器连接
 mysql_close($con);
?>